using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._SpatialStatisticsTools._Utilities
{
    /// <summary>
    /// <para>Dimension Reduction</para>
    /// <para>Reduces the number of dimensions of a set of continuous variables by aggregating the highest possible amount of variance into fewer components using Principal Component Analysis (PCA) or Reduced-Rank Linear Discriminant Analysis (LDA).</para>
    /// <para>通过使用主成分分析 （PCA） 或降秩线性判别分析 （LDA） 将尽可能高的方差聚合到更少的分量中，从而减少一组连续变量的维数。</para>
    /// </summary>    
    [DisplayName("Dimension Reduction")]
    public class DimensionReduction : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public DimensionReduction()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_table">
        /// <para>Input Table or Features</para>
        /// <para>The table or features containing the fields with the dimension that will be reduced.</para>
        /// <para>包含将缩小的维度的字段的表或要素。</para>
        /// </param>
        /// <param name="_fields">
        /// <para>Analysis Fields</para>
        /// <para>The fields representing the data with the dimension that will be reduced.</para>
        /// <para>表示将减少的维度的数据的字段。</para>
        /// </param>
        public DimensionReduction(object _in_table, List<object> _fields)
        {
            this._in_table = _in_table;
            this._fields = _fields;
        }
        public override string ToolboxName => "Spatial Statistics Tools";

        public override string ToolName => "Dimension Reduction";

        public override string CallName => "stats.DimensionReduction";

        public override List<string> AcceptEnvironments => ["outputCoordinateSystem", "randomGenerator"];

        public override object[] ParameterInfo => [_in_table, _output_data, _fields, _method.GetGPValue(), _scale.GetGPValue(), _categorical_field, _min_variance, _min_components, _append_fields.GetGPValue(), _output_eigenvalues_table, _output_eigenvectors_table, _number_of_permutations, _append_to_input.GetGPValue(), _updated_table];

        /// <summary>
        /// <para>Input Table or Features</para>
        /// <para>The table or features containing the fields with the dimension that will be reduced.</para>
        /// <para>包含将缩小的维度的字段的表或要素。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Table or Features")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_table { get; set; }


        /// <summary>
        /// <para>Output Table or Feature Class</para>
        /// <para>The output table or feature class containing the resulting components of the dimension reduction.</para>
        /// <para>包含降维结果组件的输出表或要素类。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Table or Feature Class")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _output_data { get; set; } = null;


        /// <summary>
        /// <para>Analysis Fields</para>
        /// <para>The fields representing the data with the dimension that will be reduced.</para>
        /// <para>表示将减少的维度的数据的字段。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Analysis Fields")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public List<object> _fields { get; set; }


        /// <summary>
        /// <para>Dimension Reduction Method</para>
        /// <para><xdoc>
        ///   <para>Specifies the method that will be used to reduce the dimensions of the analysis fields.</para>
        ///   <bulletList>
        ///     <bullet_item>Principal Component Analysis (PCA)—The analysis fields will be partitioned into components that each maintain the maximum proportion of the total variance. This is the default.</bullet_item><para/>
        ///     <bullet_item>Reduced-Rank Linear Discriminant Analysis (LDA)—The analysis fields will be partitioned into components that each maintain the maximum between-category separability of a categorical variable.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定将用于减小分析字段维度的方法。</para>
        ///   <bulletList>
        ///     <bullet_item>主成分分析 （PCA）—分析字段将被划分为多个分量，每个分量保持总方差的最大比例。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>降秩线性判别分析 （LDA） - 分析字段将被划分为多个组件，每个组件保持类别变量的最大类别间可分离性。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Dimension Reduction Method")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _method_value _method { get; set; } = _method_value._PCA;

        public enum _method_value
        {
            /// <summary>
            /// <para>Principal Component Analysis (PCA)</para>
            /// <para>Principal Component Analysis (PCA)—The analysis fields will be partitioned into components that each maintain the maximum proportion of the total variance. This is the default.</para>
            /// <para>主成分分析 （PCA）—分析字段将被划分为多个分量，每个分量保持总方差的最大比例。这是默认设置。</para>
            /// </summary>
            [Description("Principal Component Analysis (PCA)")]
            [GPEnumValue("PCA")]
            _PCA,

            /// <summary>
            /// <para>Reduced-Rank Linear Discriminant Analysis (LDA)</para>
            /// <para>Reduced-Rank Linear Discriminant Analysis (LDA)—The analysis fields will be partitioned into components that each maintain the maximum between-category separability of a categorical variable.</para>
            /// <para>降秩线性判别分析 （LDA） - 分析字段将被划分为多个组件，每个组件保持类别变量的最大类别间可分离性。</para>
            /// </summary>
            [Description("Reduced-Rank Linear Discriminant Analysis (LDA)")]
            [GPEnumValue("LDA")]
            _LDA,

        }

        /// <summary>
        /// <para>Scale Data</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the values of each analysis will be scaled to have a variance equal to one. This scaling ensures that each analysis field is given equal priority in the components. Scaling also removes the effect of linear units, for example, the same data measured in meters and feet will result in equivalent components. The values of the analysis fields will be shifted to have mean zero for both options.</para>
        ///   <para>
        ///     <bulletList>
        ///       <bullet_item>Checked—The values of each analysis field will be scaled to have a variance equal to one. This is the default.</bullet_item><para/>
        ///       <bullet_item>Unchecked—The variance of each analysis fields will not be scaled.</bullet_item><para/>
        ///     </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定是否将每个分析的值缩放为方差等于 1。这种缩放可确保每个分析字段在组件中具有同等的优先级。缩放还消除了线性单位的影响，例如，以米和英尺为单位测量的相同数据将产生等效的分量。对于两个选项，分析字段的值将移动为均值为零。</para>
        ///   <para>
        ///     <bulletList>
        ///       <bullet_item>选中 - 将缩放每个分析字段的值，使其方差等于 1。这是默认设置。</bullet_item><para/>
        ///       <bullet_item>未选中 - 不会缩放每个分析字段的方差。</bullet_item><para/>
        ///     </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Scale Data")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _scale_value _scale { get; set; } = _scale_value._true;

        public enum _scale_value
        {
            /// <summary>
            /// <para>SCALE_DATA</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("SCALE_DATA")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_SCALE_DATA</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_SCALE_DATA")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Categorical Field</para>
        /// <para>The field representing the categorical variable for LDA. The components will maintain the maximum amount of information needed to classify each input record into these categories.</para>
        /// <para>表示 LDA 的分类变量的字段。这些组件将保持将每个输入记录分类到这些类别所需的最大信息量。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Categorical Field")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _categorical_field { get; set; } = null;


        /// <summary>
        /// <para>Minimum Percent Variance to Maintain</para>
        /// <para>The minimum percent of total variance of the analysis fields that must be maintained in the components. The total variance depends on whether the analysis fields were scaled using the Scale Data parameter.</para>
        /// <para>必须在组件中维护的分析字段总方差的最小百分比。总方差取决于是否使用“缩放数据”参数对分析字段进行缩放。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Minimum Percent Variance to Maintain")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public double? _min_variance { get; set; } = null;


        /// <summary>
        /// <para>Minimum Number of Components</para>
        /// <para>The minimum number of components.</para>
        /// <para>组件的最小数量。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Minimum Number of Components")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long? _min_components { get; set; } = null;


        /// <summary>
        /// <para>Copy All Fields to Output Dataset</para>
        /// <para><xdoc>
        ///   <para>Specifies whether all fields from the input table or features will be copied and appended to the output table or feature class. The fields provided in the Analysis Fields parameter will be copied to the output regardless of the value of this parameter.</para>
        ///   <para>
        ///     <bulletList>
        ///       <bullet_item>Checked—All fields from the input table or features will be copied and appended to the output table or feature class.</bullet_item><para/>
        ///       <bullet_item>Unchecked—Only the analysis fields will be included in the output table or feature class. This is the default.</bullet_item><para/>
        ///     </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定是否将输入表或要素中的所有字段复制并追加到输出表或要素类中。无论此参数的值如何，分析字段参数中提供的字段都将复制到输出中。</para>
        ///   <para>
        ///     <bulletList>
        ///       <bullet_item>选中 - 输入表或要素中的所有字段都将被复制并追加到输出表或要素类中。</bullet_item><para/>
        ///       <bullet_item>未选中 - 输出表或要素类中将仅包含分析字段。这是默认设置。</bullet_item><para/>
        ///     </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Copy All Fields to Output Dataset")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _append_fields_value _append_fields { get; set; } = _append_fields_value._false;

        public enum _append_fields_value
        {
            /// <summary>
            /// <para>APPEND</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("APPEND")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_APPEND</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_APPEND")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Output Eigenvalues Table</para>
        /// <para>The output table containing the eigenvalues of each component.</para>
        /// <para>包含每个组件的特征值的输出表。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Eigenvalues Table")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _output_eigenvalues_table { get; set; } = null;


        /// <summary>
        /// <para>Output Eigenvectors Table</para>
        /// <para>The output table containing the eigenvectors of each component.</para>
        /// <para>包含每个分量的特征向量的输出表。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Output Eigenvectors Table")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _output_eigenvectors_table { get; set; } = null;


        /// <summary>
        /// <para>Number of Permutations</para>
        /// <para>The number of permutations to be used when determining the optimal number of components. The default value is 0, which indicates that no permutation test will be performed.</para>
        /// <para>确定最佳分量数时要使用的排列数。默认值为 0，表示不执行排列测试。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Number of Permutations")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public long _number_of_permutations { get; set; } = 0;


        /// <summary>
        /// <para>Append Fields to Input Data</para>
        /// <para><xdoc>
        ///   <para>Specifies whether the component fields will be appended to the input dataset or saved to an output table or feature class. If you append the fields to the input, the output coordinate system environment will be ignored.
        ///   <bulletList>
        ///     <bullet_item>Checked—The fields containing the components will be appended to the input features. This option modifies the input data.  </bullet_item><para/>
        ///     <bullet_item>Unchecked—An output table or feature class will be created containing the component fields. This is the default.  </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para><xdoc>
        /// <para>指定是将组件字段追加到输入数据集还是保存到输出表或要素类中。如果将字段追加到输入，则输出坐标系环境将被忽略。
        ///   <bulletList>
        ///     <bullet_item>选中 - 包含元件的字段将追加到输入要素中。此选项修改输入数据。 </bullet_item><para/>
        ///     <bullet_item>未选中—将创建包含元件字段的输出表或要素类。这是默认设置。 </bullet_item><para/>
        ///   </bulletList>
        ///   </para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Append Fields to Input Data")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _append_to_input_value _append_to_input { get; set; } = _append_to_input_value._false;

        public enum _append_to_input_value
        {
            /// <summary>
            /// <para>APPEND_TO_INPUT</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("APPEND_TO_INPUT")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NEW_OUTPUT</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NEW_OUTPUT")]
            [GPEnumValue("false")]
            _false,

        }

        /// <summary>
        /// <para>Updated Table or Feature Class</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Updated Table or Feature Class")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _updated_table { get; set; }


        public DimensionReduction SetEnv(object outputCoordinateSystem = null, object randomGenerator = null)
        {
            base.SetEnv(outputCoordinateSystem: outputCoordinateSystem, randomGenerator: randomGenerator);
            return this;
        }

    }

}